int getDecimalValue(ListNode* head) {
    ListNode *p = head;
    int n = 0;
    while(p)
    {
        n = n * 2 + p->val;
        p = p->next;
    }
    return n;
}